home *** CD-ROM | disk | FTP | other *** search
- Path: alibaba.kmit.sk!not-for-mail
- From: brano@alibaba (Brano Zahradnik)
- Newsgroups: comp.lang.c++
- Subject: Re: Question about destructor...
- Date: 18 Jan 1996 03:16:13 +0100
- Organization: Kmit
- Message-ID: <4dkahd$lv9@alibaba.kmit.sk>
- References: <4ce9mk$atg@eng_ser1.erg.cuhk.hk> <4cqrei$par@isoit109.bbn.hp.com>
- NNTP-Posting-Host: sk2eu.eunet.sk
- X-Newsreader: TIN [version 1.2 PL2]
-
- Manfred_Lange (Manfred_Lange@bbn.hp.com) wrote:
- : ywleung@cs.cuhk.hk (Marty McFly) wrote:
- : >Dear All,
- : >
- : > I now have 2 classes A and B. B is a derived class of A. However,
- : >the internal implementation of A is not known, i.e., the private members of
- : >class A are not provided, only the public members are given. But class B is
- : >implemented by myself. So what should be written in the destructor of B so
- : >that all the private members inherited from A are also "deleted"?
- : >
- : >Regards,
- : >Marty McFly.
- : >
- : >
-
- : Do you plan to go to the "Dance under the sea"?
-
-
- : I saw all the answers you got for your question. It is true, that you don't have
- : to care for the destructor in the baseclass.
-
- : But there is another aspect of the problem, that is important to know. Take the
- : following sample:
-
- : class Base
- : {
- : ~Base();
- : };
-
- : class Derived : public Base
- : {
- : ~Derived();
- : };
-
- : ..
-
- : { Base* aBase;
-
- : aBase = new Derived();
-
- : ...
-
- : delete aBase;
-
- : ..
-
-
- : Which destructor will be called when executing "delete aBase()" ?
-
- I think, that destructors are calling in reverse order than constructors.
- In this example: ~Derived,~Base
-
- Q: Why you need rewrite destructor of base ??
-
-